package com.apadog.study.utils;

/**
 * Created by zhengping.zhu
 * on 2017/5/7.
 * 统一返回结果集
 */
public class ResultUtil {

    /**
     * 返回成功，传入返回体具体出參
     * @param object
     * @return
     */
    public static Result success(Object object){
        Result result = new Result();
        result.setCode(200);
        result.setMsg("success");
        result.setData(object);
        return result;
    }

    /**
     * 提供给部分不需要出參的接口
     * @return
     */
    public static Result success(){
        Result result = new Result();
        result.setCode(200);
        return success(null);
    }

    /**
     * 自定义错误信息
     * @param code
     * @param msg
     * @return
     */
    public static Result error(Integer code,String msg,Object desc){
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(desc);
        return result;
    }

    public static Result error(Integer code,String msg){
        return error(code,msg,null);
    }


}
